/* GRF allocation:
   g1~g30: constant buffer
           g1~g2:intra IQ matrix
           g3~g4:non intra IQ matrix
           g5~g20:IDCT table
   g31:    thread payload 
   g58~g81:reference data
   g82:    thread payload backup
   g84~g107:IDCT data
   g115:   message descriptor for reading reference data   */
mov (8) g82.0<1>UD g31.0<8,8,1>UD {align1};
mov (1) g126.8<1>UD ip {align1};
add (1) ip g21.0<1,1,1>UD 0x50UD {align1};            //jump to the lib to do IQ and IDCT

/*field 0 of Y*/
asr (2) g31.14<1>W g82.18<2,2,1>W 1W {align1};
add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
and.nz (1) null g82.31<1,1,1>UB 0x2UW {align1};             //motion vertical field select
(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
mov (1) g115.16<1>UW 1UW {align1};           	//0:forward 1:backward
mov (1) a0.0<1>UD 0x0A52UD {align1};        	//g82.18,motion vector
mov (1) g126.8<1>UD ip {align1};
add (1) ip g21.0<1,1,1>UD 0x20UD {align1};   	//jump to the lib to read reference data 

mov (8) g58.0<1>UD g32.0<8,8,1>UD {align1};
mov (8) g60.0<1>UD g33.0<8,8,1>UD {align1};
mov (8) g62.0<1>UD g34.0<8,8,1>UD {align1};
mov (8) g64.0<1>UD g35.0<8,8,1>UD {align1};
mov (8) g66.0<1>UD g36.0<8,8,1>UD {align1};
mov (8) g68.0<1>UD g37.0<8,8,1>UD {align1};
mov (8) g70.0<1>UD g38.0<8,8,1>UD {align1};
mov (8) g72.0<1>UD g39.0<8,8,1>UD {align1};

/*field 1 of Y*/
asr (2) g31.14<1>W g82.26<2,2,1>W 1W {align1};
add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
and.nz (1) null g82.31<1,1,1>UB 0x8UW {align1};
(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
mov (1) a0.0<1>UD 0x0A5AUD {align1};		//g82.14,motion vector
mov (1) g126.8<1>UD ip {align1};
add (1) ip g21.0<1,1,1>UD 0x20UD {align1};   	//jump to the lib to read reference data 

mov (8) g59.0<1>UD g32.0<8,8,1>UD {align1};
mov (8) g61.0<1>UD g33.0<8,8,1>UD {align1};
mov (8) g63.0<1>UD g34.0<8,8,1>UD {align1};
mov (8) g65.0<1>UD g35.0<8,8,1>UD {align1};
mov (8) g67.0<1>UD g36.0<8,8,1>UD {align1};
mov (8) g69.0<1>UD g37.0<8,8,1>UD {align1};
mov (8) g71.0<1>UD g38.0<8,8,1>UD {align1};
mov (8) g73.0<1>UD g39.0<8,8,1>UD {align1};

/*field 0 of UV*/
shr (2) g31.0<1>UD g31.0<2,2,1>UD 1UD {align1};

asr (2) g31.14<1>W g82.18<2,2,1>W 2W {align1};
add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
and.nz (1) null g82.31<1,1,1>UB 0x2UW {align1};
(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
mov (1) a0.0<1>UD 0x0A52UD {align1};         //g82.18,motion vector
mov (1) g126.8<1>UD ip {align1};
add (1) ip g21.0<1,1,1>UD 0x30UD {align1};   //jump to the lib to read reference data 

mov (16) g74.0<1>UW g32.0<8,8,1>UW {align1 compr};
mov (16) g76.0<1>UW g34.0<8,8,1>UW {align1 compr};
mov (16) g78.0<1>UW g36.0<8,8,1>UW {align1 compr};
mov (16) g80.0<1>UW g38.0<8,8,1>UW {align1 compr};

/*field 1 of UV*/
asr (2) g31.14<1>W g82.26<2,2,1>W 2W {align1};
add (2) g115.0<1>UD g31.0<2,2,1>UD g31.14<2,2,1>W {align1};
and (1) g115.4<1>UD g115.4<1,1,1>UD 0xFFFFFFFEUD {align1};
and.nz (1) null g82.31<1,1,1>UB 0x8UW {align1};
(f0) add (1) g115.4<1>UD g115.4<1,1,1>UD 1UD {align1};
mov (1) a0.0<1>UD 0x0A5AUD {align1};         //g82.14,motion vector
mov (1) g126.8<1>UD ip {align1};
add (1) ip g21.0<1,1,1>UD 0x30UD {align1};   //jump to the lib to read reference data 

mov (16) g74.16<1>UW g32.0<8,8,1>UW {align1 compr};
mov (16) g76.16<1>UW g34.0<8,8,1>UW {align1 compr};
mov (16) g78.16<1>UW g36.0<8,8,1>UW {align1 compr};
mov (16) g80.16<1>UW g38.0<8,8,1>UW {align1 compr};

add (1) ip g21.0<1,1,1>UD 0x40UD {align1};          //jump to the lib to add the reference and idct data
